function [X, P3] = addView(X12_out, X22_out, X23_out, Xw12, P2)
% X12_out is inliers on frame 2 of frame pair 1 (frame pair 1 means frame 1 and frame 2)
% X22_out is inliers on frame 1 of frame pair 2 (frame pair 2 means frame 2 and frame 3) 
% X23_out is inliers on frame 2 of frame pair 2 
% Xw12 is 3D coordinates of points, reconstructed from frame pair 1 

%Find index of point correspondance in image 1-2-3 

% index11 is index of image points in frame 1 which appear in frame 2 and 3
% index13 is index of image points in frame 3 which appear in frame 1 and 2
[index11,index13]=FindIndex(X12_out,X22_out);
%Compute P3 from point correspondance
P3n = compute_p(X23_out(:,index13),Xw12(:,index11));
%P3n = compute_p(X23_out,Xw12);
h = P3n;
%Upgrade P3 for all image points in image 3
P3 = lsqnonlin(@(h)TuneP(X22_out,P2,X23_out,h),P3n);
%Reconstruct Xw for image 2 and image 3
Xw23 = Triangulation(X22_out,P2,X23_out,P3);
%Select only new reconstructed points (repeated point in Xw12 is excluded)
[indexXw23] = MakeIndex(Xw23);
[indexXw23a] = NotSameIndex(indexXw23,index13);
Xw23a = Xw23(:,indexXw23a);

X = Xw23a;